<template>
  <div class="assembly">
    <div v-if="cameraList == null||cameraList.length==0">
        <span class="fcc" style="margin-top: 10px;">没有更多了</span>
    </div>
    <div v-else>
      <div
        class="device-card"
        v-for="item in cameraList"
        :key="item.id"
        @click="handleToDetail(item)"
      >
        <h2 class="title">{{ item.regionName }}</h2>
        <div>设备名称：{{ item.name }}</div>
        <div>
          设备状态：<span :class="{ startColor: item.status === 2 }">{{
            item.status === 2 ? "在线" : "离线"
          }}</span>
        </div>
        <div>设备ip：{{ item.networkIp }}</div>
      </div>
    </div>
  </div>
</template>

<script>

import { getBiCameraList,getBiCameraList_qy } from "@/api/cctv";
export default {
  data() {
    return {
      cameraList: [],
    };
  },
  created() {
    // value === "undefined" || value === null
    if (this.$route.query.CompanyCode) {
      console.log(this.$route.query.CompanyCode);
      // this.$store.state.CompanyCode=this.$route.query.CompanyCode
      //拿query的
      localStorage.setItem("CompanyCode2", this.$route.query.CompanyCode);
    } else {
      //拿登录的
      localStorage.setItem("CompanyCode2", this.$store.state.CompanyCode);
    }

    this.getCamList();
  },

  methods: {

    
    async getCamList() {
      let result
      if(process.env.VUE_APP_PLANTFORM&&process.env.VUE_APP_PLANTFORM=="QYAQ"){
         result = await getBiCameraList_qy();
      }else{
         result = await getBiCameraList({});
      }
      
      this.cameraList = result;
      
    },
    handleToDetail(item) {
      localStorage.setItem("cctvDetail", JSON.stringify(item));
      this.$router.push(`/cctv/detail`);
    },
  },
};
</script>

<style scoped>
.title {
  font-size: 16px;
  color: #333;
}
.device-card {
  margin: 10px;
  padding: 15px 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-direction: column;
  background-color: #fff;
  border-radius: 10px;
  font-size: 14px;
  color: #929292;
}
.startColor {
  color: #7ca965;
}
</style>

